<?php
/**
 * Created by PhpStorm.
 * User: coolinmind
 * Date: 01/03/2019
 * Time: 16:13
 */

namespace App\Modules\UCenter;


use App\Services\Setting\SettingIndex;
use App\Services\UCenter\CommentIndex;

class Comment extends BaseUcenter
{
    /**
     * 获取评价筛选项
     * @return array
     */
    public function getDriverSelection()
    {
        $data = $this->postData;
        $selection = SettingIndex::SettingCategory()->getSelection(['action' => $data['action']]);
        return auto_return($selection);
    }

    /**
     * 发表评论
     */
    public function addComment()
    {
        $res = $this->isLogin();
        if ($res['status'] !== SUCCESS_STATUS) {
            return need_login($res,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $res['res']['id'];
        $data['role_ids'] = $res['res']['role_ids'];
        return CommentIndex::Comment()->addComment($data);
    }

    /**
     * 获取用户评价标签统计数据
     * @return array
     */
    public function getCommentStatistics()
    {
        $res = $this->isLogin();
        if ($res['status'] !== SUCCESS_STATUS) {
            return need_login($res,'请登录');
        }
        $data = $this->postData;
        $data['user_id'] = $res['res']['id'];
        $data['role_ids'] = $res['res']['role_ids'];
        return CommentIndex::Comment()->getCommentStatistics($data);
    }
}
